<link href="<?php echo base_url();?>public/skin/back-end/css/ajaxfileupload.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<?php echo base_url();?>public/skin/back-end/js/ajaxfileupload.js"></script>
<script type="text/javascript">
function ajaxFileUpload()
{
	$("#loading")
	.ajaxStart(function(){
		$("#result").hide();
		$(this).show();
	})
	.ajaxComplete(function(){
		$(this).hide();
		$("#result").show();
	});

	$.ajaxFileUpload
	(
		{
			url:'<?php echo base_url();?>admin/gallery_management/upload_picture.html?id=<?php echo $current_picture['id'];?>',
			secureuri:false,
			fileElementId:'Filedata',
			dataType: 'json',
			success: function (data, status)
			{
				//alert(data.record.id);
				$("#result").html(data.msg);
				$("#img_<?php echo $current_picture['id'];?>").attr("src",data.url);				
				
			},
			error: function (data, status, e)
			{
				$("#result").html(e);
			}
		}
	)
	
	return false;

}
</script>	  
		<table cellpadding="0" cellspacing="10" class="tableForm">
			<tr>
				<td class="namefield">Image URL</td>
				<td class="boxfields">
					<input id="Filedata" type="file" size="20" name="Filedata" class="input" onChange="ajaxFileUpload();">
					<div id="loading" style="display:none">Uploading...</div>
					<div id="result"><?php echo $current_picture['url'];?></div>
				</td></tr>	
	</table>
	
	<form id="picture-form">
		<table cellpadding="0" cellspacing="10">
        <tr>
          <td class="namefield">Description:&nbsp;</td>
          <td class="boxfields">
          	<textarea style="width: 98%; height: 100px;" id="description" name="description"><?php echo $current_picture['description'];?></textarea>
          </td>
        </tr>
        <tr>
          <td class="namefield">Language :&nbsp;</td>
          <td class="boxfields">
          	<?php echo form_dropdown('language', $langList,$current_picture['language'])?>
          </td>
        </tr>
        <tr>
          <td class="namefield">Order :&nbsp;</td>
          <td class="boxfields">
          	<?php 
          		$this->load->helper('form');
          		$options = array();
          		for($i=1;$i<=$max_order;$i++){
          			$options[$i]=$i;
          		}
				echo form_dropdown('order', $options, $current_picture['order']);
          	?>
          </td>
        </tr>
      </table>
      <input type="hidden" name="folder_id" value="<?php echo $fid;?>">
      <input type="hidden" name="id" value="<?php echo $current_picture['id'];?>">
      <input name="submit" type="submit" value="Save" />
	</form>
<script language="JavaScript" type="text/javascript">    
$(document).ready(function() {
	var options = {
            dataType: 'json',
            beforeSubmit:  function(formData, jqForm, options) {
            	$.prompt('Please wait...',{ buttons: {},zIndex: 20005 });
        	    return true;
            },
            url: '<?php echo base_url();?>admin/gallery_management/add_picture',
            type: 'post',  // pre-submit callback
            success: function (responseText, statusText) {
                jQuery.prompt.close();
                if(responseText.success == true){
    				$.prompt('Saved Successfully!',{ buttons: { Ok: true },zIndex: 20005 });
    				ajaxListImages(<?php echo $start;?>,<?php echo $fid;?>);
    				parent.tb_remove();			    				
        		}
    			else $.prompt('Can not save!',{ buttons: { Ok: true },zIndex: 20005 });
	        	return false;
            },
            error: function (responseText, statusText){
                jQuery.prompt.close();
            	$.prompt('Can not save!',{ buttons: { Ok: true },zIndex: 20005 });
            	return false;
            }
     };	
	$('#picture-form').submit(function() {
		$("#picture-form").ajaxSubmit(options); 
		  return false;
		});
						
});	
</script>